<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-9-19
 * Func   江苏快3
 */
defined('IN_YuLin') || exit('NO PERMIT!');

//	返回中奖金额	data为订单信息，plays为玩法

function PrizeCount_5($data,$plays)
{
	if(!$data || !$data['result'] || !$plays)
	{
		return 0;
	}
	
	//	玩法
	$result = explode(',',$data['result']);
	
	//	二同号单选
	if($plays['playid'] == 21334)
	{
		//	二同号最多2个数
		$tmp2 = array_count_values($result);
		if(count($tmp2) > 2)
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		
		$tmp0 = $tmp1 = 0;
		foreach($tmp[0] as $t)
		{
			$t = substr($t,1);	//	同号，取一个数字即可
			$tmp2[$t] > 1 && $tmp0++;	//	3个即豹子
		}
		foreach($tmp[1] as $t)
		{
			$tmp2[$t] == 1 && $tmp1++;
		}
		
		return $tmp0 && $tmp1 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	二同号复选
	if($plays['playid'] == 21335)
	{
		//	二同号最多2个数
		$tmp2 = array_count_values($result);
		if(count($tmp2) > 2)
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		
		$tmp0 = 0;
		foreach($tmp as $t)
		{
			$t = substr($t,1);	//	同号，取一个数字即可
			$tmp2[$t] > 1 && $tmp0++;
		}
		
		return $tmp0 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	三同号单选
	if($plays['playid'] == 21336)
	{
		//	必须是豹子
		$tmp2 = array_count_values($result);
		if(count($tmp2) != 3)
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		
		return in_array(implode('',$result),$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	三同号复选
	if($plays['playid'] == 21337)
	{
		//	必须是豹子
		$tmp2 = array_count_values($result);
		
		return (count($tmp2) == 3) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	和值
	if($plays['parentid'] == 1774)
	{
		$hezhi = array_sum($result);
		
		return $data['rednum'] == $hezhi ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	三连号通选
	if($plays['playid'] == 21346)
	{
		return in_array(implode('',$result),[123,234,345,456]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	二不同号
	if($plays['playid'] == 21347)
	{
		//	必须三个数不一样
		$tmp2 = array_count_values($result);
		if(count($tmp2) < 3)
		{
			return 0;
		}
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($result as $t)
		{
			in_array($t,$tmp) && $tmp3++;
		}
		
		return $tmp3 > 1 ? NumGroup($tmp3,2) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	三不同号
	if($plays['playid'] == 21348)
	{
		//	必须三个数不一样
		$tmp2 = array_count_values($result);
		if(count($tmp2) < 3)
		{
			return 0;
		}
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($result as $t)
		{
			in_array($t,$tmp) && $tmp3++;
		}
		
		return $tmp3 > 2 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	return 0;
}